{% extends 'base.html' %}

{% block title %}编辑个人资料 - 知疑{% endblock %}

{% block content %}
<div class="row justify-content-center">
    <div class="col-md-8">
        <div class="card">
            <div class="card-header">
                <h4 class="mb-0">编辑个人资料</h4>
            </div>
            <div class="card-body">
                <form method="POST" enctype="multipart/form-data">
                    {{ form.hidden_tag() }}
                    
                    <div class="mb-3">
                        {{ form.username.label(class="form-label") }}
                        {% if form.username.errors %}
                            {{ form.username(class="form-control is-invalid") }}
                            <div class="invalid-feedback">
                                {% for error in form.username.errors %}
                                    {{ error }}
                                {% endfor %}
                            </div>
                        {% else %}
                            {{ form.username(class="form-control") }}
                        {% endif %}
                    </div>
                    
                    <div class="mb-3">
                        {{ form.email.label(class="form-label") }}
                        {% if form.email.errors %}
                            {{ form.email(class="form-control is-invalid") }}
                            <div class="invalid-feedback">
                                {% for error in form.email.errors %}
                                    {{ error }}
                                {% endfor %}
                            </div>
                        {% else %}
                            {{ form.email(class="form-control") }}
                        {% endif %}
                    </div>
                    
                    <div class="mb-3">
                        {{ form.about_me.label(class="form-label") }}
                        {% if form.about_me.errors %}
                            {{ form.about_me(class="form-control is-invalid", rows=5) }}
                            <div class="invalid-feedback">
                                {% for error in form.about_me.errors %}
                                    {{ error }}
                                {% endfor %}
                            </div>
                        {% else %}
                            {{ form.about_me(class="form-control", rows=5) }}
                        {% endif %}
                    </div>
                    
                    <div class="mb-3">
                        {{ form.avatar.label(class="form-label") }}
                        {% if form.avatar.errors %}
                            {{ form.avatar(class="form-control is-invalid") }}
                            <div class="invalid-feedback">
                                {% for error in form.avatar.errors %}
                                    {{ error }}
                                {% endfor %}
                            </div>
                        {% else %}
                            {{ form.avatar(class="form-control") }}
                        {% endif %}
                        <div class="form-text">当前头像: <img src="{{ url_for('static', filename='img/' + current_user.avatar) }}" class="avatar-sm ms-2"></div>
                    </div>
                    
                    <div class="d-flex justify-content-between">
                        <a href="{{ url_for('user.profile', username=current_user.username) }}" class="btn btn-secondary">
                            <i class="fas fa-times me-1"></i>取消
                        </a>
                        {{ form.submit(class="btn btn-primary") }}
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
{% endblock %} 